package database_interaction;

import java.sql.Time;
import java.util.Date;

/**
 * @file SQLDateTime.java
 * @version 0.1
 * @author James Dibble 10009689
 */
public class DateTime extends Parameter {
    // <editor-fold defaultstate="collapsed" desc="Attributes">
    private Date _date;
    private Time _time;
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Constructors">
    /**
     * Instance of a MySQL date.
     * @param date
     * @param time 
     */
    public DateTime(Date date, Time time) {
        super(SQLType.DateTime);
        this._date = date;
        this._time = time;
    }
    
    @SuppressWarnings("deprecation")
	public DateTime(int year, int month, int day, int hour, int minute, int second){
        super(SQLType.DateTime);
        _date = new Date(year, month, day);
        _time = new Time(hour, minute, second);
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Methods">
    /**
     * Get the datetime stamp in a MySQL format YYYY-MM-DD hh:mm:ss
     * 
     * @return MySQL format datetime.
     */
    @SuppressWarnings("deprecation")
	@Override
    public String toString(){
        return String.format("%s-%s-%s %s",
                            _date.getYear(),
                            _date.getMonth(),
                            _date.getDay(),
                            _time.toString());
    }
    
    @Override
    public Object value() {
        return this;
    }
    
    /**
     * Get the date part of this DateTime.
     * 
     * @return 
     */
    public Date getDate(){
        return this._date;
    }
    
    /**
     * Get the time part of this DateTime.
     * 
     * @return 
     */
    public Time getTime(){
        return this._time;
    }
    // </editor-fold>
}
